<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<title>活动报名管理系统注册</title>
	<meta name="keywords" content="活动报名管理系统注册" />
	<meta name="description" content="活动报名管理系统注册" />

	<link rel="stylesheet" type="text/css" href="/static/css/login/vendor/bootstrap/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="/static/css/login/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
	<link rel="stylesheet" type="text/css" href="/static/css/login/fonts/iconic/css/material-design-iconic-font.min.css">
	<link rel="stylesheet" type="text/css" href="/static/css/login/css/util.css">
	<link rel="stylesheet" type="text/css" href="/static/css/login/css/main.css">
	<style>
		/*html {filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);-webkit-filter: grayscale(100%);}*/
	</style>
</head>

<body>

<div class="limiter">
	<div class="container-login100" style="background-image: url('/static/images/containerbg.png');">
		<div class="wrap-login100 p-l-55 p-r-55 p-t-65 p-b-54">
			<form class="login100-form validate-form" id="loginformbtn">
				<span class="login100-form-title p-b-49">活动报名管理系统注册</span>

				<div class="wrap-input100 validate-input m-b-23" data-validate="请输入账号">
					<span class="label-input100">用户名</span>
					<input class="input100" type="text" name="membername" id="memberName" placeholder="请输入账号" autocomplete="off">
					<span class="focus-input100" data-symbol="&#xf206;"></span>
				</div>

				<div class="wrap-input100 validate-input m-b-23" data-validate="请输入密码">
					<span class="label-input100">密码</span>
					<input class="input100" type="password" name="memberpassword" id="memberPassword" placeholder="请输入密码" autocomplete="off">
					<span class="focus-input100" data-symbol="&#xf190;"></span>
				</div>

				<div class="wrap-input100 validate-input m-b-23" data-validate="请输入生日">
					<span class="label-input100">生日</span>
					<input class="input100" type="date" name="memberbirthdate" id="memberBirthdate" placeholder="请输入生日">
					<span class="focus-input100" data-symbol="&#xf291;"></span>
				</div>

				<div class="wrap-input100 validate-input m-b-23" data-validate="请输入性别">
					<span class="label-input100">性别</span>
					<select class="input100" name="membersex">
						<option value="男">男</option>
						<option value="女">女</option>
					</select>
					<span class="focus-input100" data-symbol="&#xf132;"></span>
				</div>

				<div class="wrap-input100 validate-input m-b-23" data-validate="请输入邮箱">
					<span class="label-input100">邮箱</span>
					<input class="input100" type="text" name="memberemail" id="memberEmail" placeholder="请输入邮箱">
					<span class="focus-input100" data-symbol="&#xf261;"></span>
				</div>

				<div class="wrap-input100 validate-input m-b-23" data-validate="注册类型">
					<span class="label-input100">注册类型</span>
					<select class="input100" name="type" id="type">
						<option value="1">管理员</option>
						<option value="2">成员</option>
					</select>
					<span class="focus-input100" data-symbol="&#xf152;"></span>
				</div>

			    <div class="text-right p-t-8 p-b-31">
					<a href="/login.jsp"  id="reloadPwd">已有账号，立即登录？</a>
				</div>

				<div class="container-login100-form-btn">
					<div class="wrap-login100-form-btn">
						<div class="login100-form-bgbtn"></div>
						<button class="login100-form-btn" id="btnform" onclick="keyLogin()">注 册</button>
					</div>
				</div>

			</form>
		</div>
	</div>
</div>

<script src="/static/css/login/vendor/jquery/jquery-3.2.1.min.js"></script>
<script src="/static/css/login/js/main.js"></script>
<script type="text/javascript" src="/static/lib/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/xadmin.js"></script>
<script type="text/javascript">

	window.onload = function () {
		if (window.parent.window != window) {
			window.top.location = "/";
		}
	}

	function validate (input) {
		var memberName=$("#memberName").val();
		if(memberName==''){
			alert("账号不能为空");
			return false;
		}
		var memberPassword=$("#memberPassword").val();
		if(memberPassword==''){
			alert("密码不能为空");
			return false;
		}
		var memberBirthdate=$("#memberBirthdate").val();
		if(memberBirthdate==''){
			alert("生日不能为空");
			return false;
		}
		var memberEmail=$("#memberEmail").val();
		if(memberEmail==''){
			alert("邮箱不能为空");
			return false;
		}else{
			if(memberEmail.match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) {
				alert("邮箱格式不正确");
				return false;
			}
		}
		return true;
	}

	$("#btnform").on("click",function(){
        if(validate()){
			var index;
			$.ajax({
				url : "/LoginServlet?method=register",
				data:$('#loginformbtn').serialize(),
				type : "POST",
				dataType : "json",
				beforeSend:function(XMLHttpRequest){
					index= layer.msg('登录中，请稍候',{icon: 16,time:false,shade:0.8});
				},success : function(data){
					if(data.success){
						layer.alert(data.msg,{icon:1});
					}else{
						layer.alert(data.msg,{icon:5});
					}
				},complete:function(XMLHttpRequest,textStatus){
					layer.close(index);
				},error:function(data){
					layer.alert('网络异常或者数据错误', {icon: 2});
				}
			})
			return false;
		}
		return false;
	})


	function keyLogin(){
		if (event.keyCode==13)  //回车键的键值为13
			document.getElementById("loginbtn").click(); //调用登录按钮的登录事件
	}

</script>
</body>
</html>
